package com.ruoyi.project.cms.service.impl;

import java.util.List;

import com.ruoyi.common.constant.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.cms.mapper.CmsMatterAlbumMapper;
import com.ruoyi.project.cms.domain.CmsMatterAlbum;
import com.ruoyi.project.cms.service.ICmsMatterAlbumService;

/**
 * 素材文件夹Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-09
 */
@Service
public class CmsMatterAlbumServiceImpl implements ICmsMatterAlbumService 
{
    @Autowired
    private CmsMatterAlbumMapper cmsMatterAlbumMapper;

    /**
     * 查询素材文件夹
     * 
     * @param id 素材文件夹ID
     * @return 素材文件夹
     */
    @Override
    public CmsMatterAlbum selectCmsMatterAlbumById(Long id)
    {
        return cmsMatterAlbumMapper.selectCmsMatterAlbumById(id);
    }

    /**
     * 查询素材文件夹列表
     * 
     * @param cmsMatterAlbum 素材文件夹
     * @return 素材文件夹
     */
    @Override
    public List<CmsMatterAlbum> selectCmsMatterAlbumList(CmsMatterAlbum cmsMatterAlbum)
    {
        return cmsMatterAlbumMapper.selectCmsMatterAlbumList(cmsMatterAlbum);
    }

    /**
     * 新增素材文件夹
     * 
     * @param cmsMatterAlbum 素材文件夹
     * @return 结果
     */
    @Override
    public int insertCmsMatterAlbum(CmsMatterAlbum cmsMatterAlbum)
    {
        return cmsMatterAlbumMapper.insertCmsMatterAlbum(cmsMatterAlbum);
    }

    /**
     * 修改素材文件夹
     * 
     * @param cmsMatterAlbum 素材文件夹
     * @return 结果
     */
    @Override
    public int updateCmsMatterAlbum(CmsMatterAlbum cmsMatterAlbum)
    {
        return cmsMatterAlbumMapper.updateCmsMatterAlbum(cmsMatterAlbum);
    }

    /**
     * 批量删除素材文件夹
     * 
     * @param ids 需要删除的素材文件夹ID
     * @return 结果
     */
    @Override
    public int deleteCmsMatterAlbumByIds(Long[] ids)
    {
        return cmsMatterAlbumMapper.deleteCmsMatterAlbumByIds(ids);
    }

    /**
     * 删除素材文件夹信息
     * 
     * @param id 素材文件夹ID
     * @return 结果
     */
    @Override
    public int deleteCmsMatterAlbumById(Long id)
    {
        return cmsMatterAlbumMapper.deleteCmsMatterAlbumById(id);
    }

    @Override
    public int deleteAlbumByIds(Long[] ids) {
        for (Long id : ids){
            CmsMatterAlbum cmsMatterAlbum = selectCmsMatterAlbumById(id);
            cmsMatterAlbum.setIsDel(Constants.SYS_YES);
            updateCmsMatterAlbum(cmsMatterAlbum);
        }
        return 1;
    }
}
